package com.csi.controller;

import com.csi.domain.Guide;
import com.csi.service.GuideService;
import com.csi.utils.JsonResult;
import com.csi.utils.ReturnResults;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/guide")
public class GuideController {

    @Autowired
    private GuideService guideService;

    @GetMapping("/findById")
    @Operation(summary = "根据导演ID查询导游信息")
    public Object findById(@RequestParam("id") Integer id) {
        Guide guide = guideService.findById(id);
        if (guide != null) {
            return new JsonResult<>(guide);
        }
        return new JsonResult<>(ReturnResults.ACCESS_FAILED,"失败了");
    }

    @GetMapping("/findAll")
    @Operation(summary = "查找全部导游")
    public Object findAll(){
        List<Guide> guides = guideService.findAll();
        if (guides != null){
            return new JsonResult<>(guides);
        }
        return new JsonResult<>(ReturnResults.ACCESS_FAILED,"查询失败");
    }
}
